#include <QApplication>
#include <QTranslator>
#include <QLocale>
#include <QSettings>
#include "ide.h"
#include "mimainwindow.h"

int main( int argc, char* argv[] ) {

    QApplication app(argc, argv);
    QTranslator translator;
    QLocale locale;


    app.setApplicationName( "MuddyIDE" );
    app.setApplicationVersion( "0.0.1" );
    app.setOrganizationName( "HMCsoft" );

    QSettings set;

    if( set.contains( "language" ) ) {
        translator.load( QApplication::tr( "lang/" ) + set.value("language","english").toString() );
    } else {
          translator.load( QApplication::tr( "lang/" ) +  locale.languageToString( locale.language() ) );
    }
    app.installTranslator(&translator);

    //MIPluginList* plugins = findPlugins();
    //plugins

    MIMainWindow* mw = loadGUI( app );
    mw->setWindowIcon( QIcon(":/images/muddy_ide2.png") );
    mw->setWindowTitle( mw->tr("MuddyIDE") );
    mw->restoreGeometry(set.value("window/Geometry","0").toByteArray());

    mw->show();

    if( set.value("startWithGS", true).toBool() ) {
        mw->gettingStartedTab();
    } else {
        mw->slotNewTab();
    }


    int retval = app.exec();

    //saving window geometry
    set.setValue("window/Geometry", mw->saveGeometry());

    return retval;


}

